/**
 * @classes.ts 
 * 关于typescript 类的语法示例
 */


 /**
  * 类示例：继承，公有，私有 ，抽象
  * @class Animal
  */
 abstract class CAnimal 
 {
     // 只读属性，只读属性必须在声明时或构造函数里被初始化。
     readonly numberOfLegs : number = 0;
     
    private name : string;
    public constructor(theName:string) {
        this.name = theName;
    } 
    public move(distanceInMeters:number) {
        console.log(`${this.name} moved ${distanceInMeters}m`);
    }

    abstract makeSound(): void;
 }

 class CSnake extends CAnimal
 {
    public constructor(theName:string) {
        super(theName);
    }

    public move(distanceInMeters=5) {
        console.log("Slithering....");
        super.move(distanceInMeters);
    }

    public makeSound() : void {
        return;
    }

 }

 class CHorse extends CAnimal
 {
     public constructor(theName : string) {
         super(theName);
     }

     public move(distanceInMeters=45) {
         console.log("Galloping...");
         super.move(distanceInMeters);
     }

    public makeSound() : void {
        return;
    }
 }

 let sam = new CSnake("Sammy the Python");
 let tom : CAnimal = new CHorse("Tommy the Palomino");

 sam.move();
 tom.move(35);

/**
 * 类的存取器示例
 * @class Employee
 */
class Employee {
    private _fullName : string;

    public get fullName(): string {
        return this._fullName;
    };
    public set fullName(value: string) {
        this._fullName = value;
    };
 }

 
 interface NotEmpty<T> {
    data: T;
}
let x: NotEmpty<number>;
let y: NotEmpty<string>;